Add a KML read test, lame as it is...
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 23 Aug 2013 03:05:37 +0000 (03:05 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 23 Aug 2013 03:05:37 +0000 (03:05 +0000)
gpsbabel/reference/kml-points.kml [new file with mode: 0644]
gpsbabel/reference/kml-points.txt [new file with mode: 0644]
gpsbabel/testo.d/kml-read.test [new file with mode: 0644]
gpsbabel/text.cc

diff --git a/gpsbabel/reference/kml-points.kml b/gpsbabel/reference/kml-points.kml
new file mode 100644 (file)
index 0000000..fb5a08d
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
+  <Document>
+    <name>GPS device</name>
+    <snippet>Created Thu Aug 22 22:03:14 2013</snippet>
+    <LookAt>
+      <longitude>-86.877408</longitude>
+      <latitude>36.042108</latitude>
+      <range>63537.698405</range>
+    </LookAt>
+    <!-- Normal waypoint style -->
+    <Style id="waypoint_n">
+      <IconStyle>
+        <Icon>
+          <href>http://maps.google.com/mapfiles/kml/pal4/icon61.png</href>
+        </Icon>
+      </IconStyle>
+    </Style>
+    <!-- Highlighted waypoint style -->
+    <Style id="waypoint_h">
+      <IconStyle>
+        <scale>1.2</scale>
+        <Icon>
+          <href>http://maps.google.com/mapfiles/kml/pal4/icon61.png</href>
+        </Icon>
+      </IconStyle>
+    </Style>
+    <StyleMap id="waypoint">
+      <Pair>
+        <key>normal</key>
+        <styleUrl>#waypoint_n</styleUrl>
+      </Pair>
+      <Pair>
+        <key>highlight</key>
+        <styleUrl>#waypoint_h</styleUrl>
+      </Pair>
+    </StyleMap>
+    <Folder>
+      <name>Waypoints</name>
+      <Placemark>
+        <name>GCEBB</name>
+        <snippet/>
+        <description><![CDATA[<a href="http://www.geocaching.com/seek/cache_details.asp?ID=3771">Cache Details</a>]]></description>
+        <styleUrl>#waypoint</styleUrl>
+        <Point>
+          <coordinates>-87.134700,35.972033</coordinates>
+        </Point>
+      </Placemark>
+      <Placemark>
+        <name>GC1A37</name>
+        <snippet/>
+        <description><![CDATA[<a href="http://www.geocaching.com/seek/cache_details.asp?ID=6711">Cache Details</a>]]></description>
+        <styleUrl>#waypoint</styleUrl>
+        <Point>
+          <coordinates>-86.679550,36.090683</coordinates>
+        </Point>
+      </Placemark>
+      <Placemark>
+        <name>GC1C2B</name>
+        <snippet/>
+        <description><![CDATA[<a href="http://www.geocaching.com/seek/cache_details.asp?ID=7211">Cache Details</a>]]></description>
+        <styleUrl>#waypoint</styleUrl>
+        <Point>
+          <coordinates>-86.620117,35.996267</coordinates>
+        </Point>
+      </Placemark>
+      <Placemark>
+        <name>GC25A9</name>
+        <snippet/>
+        <description><![CDATA[<a href="http://www.geocaching.com/seek/cache_details.asp?ID=9641">Cache Details</a>]]></description>
+        <styleUrl>#waypoint</styleUrl>
+        <Point>
+          <coordinates>-86.648617,36.038483</coordinates>
+        </Point>
+      </Placemark>
+      <Placemark>
+        <name>GC2723</name>
+        <snippet/>
+        <description><![CDATA[<a href="http://www.geocaching.com/seek/cache_details.asp?ID=10019">Cache Details</a>]]></description>
+        <styleUrl>#waypoint</styleUrl>
+        <Point>
+          <coordinates>-86.741767,36.112183</coordinates>
+        </Point>
+      </Placemark>
+      <Placemark>
+        <name>GC2B71</name>
+        <snippet/>
+        <description><![CDATA[<a href="http://www.geocaching.com/seek/cache_details.asp?ID=11121">Cache Details</a>]]></description>
+        <styleUrl>#waypoint</styleUrl>
+        <Point>
+          <coordinates>-86.790517,36.064083</coordinates>
+        </Point>
+      </Placemark>
+      <Placemark>
+        <name>GC309F</name>
+        <snippet/>
+        <description><![CDATA[<a href="http://www.geocaching.com/seek/cache_details.asp?ID=12447">Cache Details</a>]]></description>
+        <styleUrl>#waypoint</styleUrl>
+        <Point>
+          <coordinates>-86.809733,36.087767</coordinates>
+        </Point>
+      </Placemark>
+      <Placemark>
+        <name>GC317A</name>
+        <snippet/>
+        <description><![CDATA[<a href="http://www.geocaching.com/seek/cache_details.asp?ID=12666">Cache Details</a>]]></description>
+        <styleUrl>#waypoint</styleUrl>
+        <Point>
+          <coordinates>-86.892000,36.057500</coordinates>
+        </Point>
+      </Placemark>
+      <Placemark>
+        <name>GC317D</name>
+        <snippet/>
+        <description><![CDATA[<a href="http://www.geocaching.com/seek/cache_details.asp?ID=12669">Cache Details</a>]]></description>
+        <styleUrl>#waypoint</styleUrl>
+        <Point>
+          <coordinates>-86.867283,36.082800</coordinates>
+        </Point>
+      </Placemark>
+    </Folder>
+  </Document>
+</kml>
diff --git a/gpsbabel/reference/kml-points.txt b/gpsbabel/reference/kml-points.txt
new file mode 100644 (file)
index 0000000..71fca78
--- /dev/null
@@ -0,0 +1,10 @@
+No,Latitude,Longitude,Name,Description\r
+1,35.972033,-87.134700,"GCEBB","<a href=""http://www.geocaching.com/seek/cache_details.asp?ID=3771"">Cache Details</a>"\r
+2,36.090683,-86.679550,"GC1A37","<a href=""http://www.geocaching.com/seek/cache_details.asp?ID=6711"">Cache Details</a>"\r
+3,35.996267,-86.620117,"GC1C2B","<a href=""http://www.geocaching.com/seek/cache_details.asp?ID=7211"">Cache Details</a>"\r
+4,36.038483,-86.648617,"GC25A9","<a href=""http://www.geocaching.com/seek/cache_details.asp?ID=9641"">Cache Details</a>"\r
+5,36.112183,-86.741767,"GC2723","<a href=""http://www.geocaching.com/seek/cache_details.asp?ID=10019"">Cache Details</a>"\r
+6,36.064083,-86.790517,"GC2B71","<a href=""http://www.geocaching.com/seek/cache_details.asp?ID=11121"">Cache Details</a>"\r
+7,36.087767,-86.809733,"GC309F","<a href=""http://www.geocaching.com/seek/cache_details.asp?ID=12447"">Cache Details</a>"\r
+8,36.057500,-86.892000,"GC317A","<a href=""http://www.geocaching.com/seek/cache_details.asp?ID=12666"">Cache Details</a>"\r
+9,36.082800,-86.867283,"GC317D","<a href=""http://www.geocaching.com/seek/cache_details.asp?ID=12669"">Cache Details</a>"\r
diff --git a/gpsbabel/testo.d/kml-read.test b/gpsbabel/testo.d/kml-read.test
new file mode 100644 (file)
index 0000000..2030023
--- /dev/null
@@ -0,0 +1,8 @@
+# Test KML reader.
+# Coverage here is lower than in our writer, but this is somewhat OK
+# as real world usage shows our writer is more frequently used than our
+# reader.
+
+# gpsbabel -i geo -f geocaching.loc -o unicsv -F ${TMPDIR}/geocaching.txt
+gpsbabel -i kml -f ${REFERENCE}/kml-points.kml -o unicsv -F ${TMPDIR}/geo~unicsv.txt
+compare ${REFERENCE}/kml-points.txt ${TMPDIR}/geo~unicsv.txt
index bc25f334fe6e0ca8253c92c2f9f4b1c8c3cc5c9f..80f2910db659a58f702811a56233f97e6a204cdb 100644 (file)
@@ -118,12 +118,6 @@ text_disp(const waypoint* wpt)
 
   GPS_Math_WGS84_To_UTM_EN(wpt->latitude, wpt->longitude,
                            &utme, &utmn, &utmz, &utmzc);
-#if 0
-  if (tm == 0) {
-    tm = time(NULL);
-  }
-  strftime(tbuf, sizeof(tbuf), "%d-%b-%Y", localtime(&tm));
-#endif
   tmpout1 = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], " ", 0);
   if (wpt->altitude != unknown_alt) {
     xasprintf(&altout, " alt:%d", (int)((altunits[0]=='f')?METERS_TO_FEET(wpt->altitude):wpt->altitude));